name = "cargo"
version = "0.1.0"
dependencies = [
- "advapi32-sys 0.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "curl 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)",
- "docopt 0.6.34 (registry+https://github.com/rust-lang/crates.io-index)",
+ "advapi32-sys 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
+ "curl 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)",
+ "docopt 0.6.35 (registry+https://github.com/rust-lang/crates.io-index)",
"env_logger 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "flate2 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
- "git2 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)",
- "glob 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
+ "flate2 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
+ "git2 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)",
+ "glob 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
"hamcrest 0.1.0 (git+https://github.com/carllerche/hamcrest-rust.git)",
"log 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"regex 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)",
"registry 0.1.0",
- "rustc-serialize 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rustc-serialize 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)",
"semver 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)",
"tar 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
"term 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)",
"time 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)",
"toml 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)",
- "url 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)",
- "winapi 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
+ "url 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)",
+ "winapi 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "advapi32-sys"
-version = "0.0.2"
+version = "0.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "winapi 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
+ "winapi 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
[[package]]
name = "curl"
-version = "0.1.13"
+version = "0.1.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"curl-sys 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"openssl-sys 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "url 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)",
+ "url 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
[[package]]
name = "docopt"
-version = "0.6.34"
+version = "0.6.35"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"regex 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)",
- "rustc-serialize 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rustc-serialize 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
[[package]]
name = "flate2"
-version = "0.1.7"
+version = "0.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"libc 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "miniz-sys 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "miniz-sys 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
[[package]]
name = "git2"
-version = "0.1.13"
+version = "0.1.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"bitflags 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "libgit2-sys 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)",
- "url 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libgit2-sys 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)",
+ "url 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "glob"
-version = "0.1.8"
+version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
version = "0.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "winapi 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
+ "winapi 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
[[package]]
name = "libgit2-sys"
-version = "0.1.11"
+version = "0.1.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"libssh2-sys 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
[[package]]
name = "miniz-sys"
-version = "0.1.1"
+version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"gcc 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "registry"
version = "0.1.0"
dependencies = [
- "curl 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)",
- "rustc-serialize 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
+ "curl 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rustc-serialize 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "rustc-serialize"
-version = "0.2.11"
+version = "0.2.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
dependencies = [
"kernel32-sys 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "winapi 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
+ "winapi 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
version = "0.1.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "rustc-serialize 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rustc-serialize 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "url"
-version = "0.2.18"
+version = "0.2.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"matches 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "rustc-serialize 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rustc-serialize 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "winapi"
-version = "0.1.8"
+version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
None => Ok(None),
Some(err) => {
Err(match err.exit {
- Some(ExitStatus(i)) => CliError::new("", i as u32),
+ Some(ExitStatus(i)) => CliError::new("", i as i32),
_ => CliError::from_boxed(box Human(err), 101)
})
}
-#![feature(collections, core, io, os, path)]
+#![feature(collections, core, io, path, env)]
extern crate "rustc-serialize" as rustc_serialize;
extern crate cargo;
-#[macro_use] extern crate log;
extern crate env_logger;
+#[macro_use] extern crate log;
use std::collections::BTreeSet;
-use std::os;
-use std::old_io;
+use std::env;
use std::old_io::fs::{self, PathExtensions};
use std::old_io::process::{Command,InheritFd,ExitStatus,ExitSignal};
+use std::old_io;
use cargo::{execute_main_without_stdin, handle_error, shell};
use cargo::core::MultiShell;
on this top-level information.
*/
fn execute(flags: Flags, config: &Config) -> CliResult<Option<()>> {
- debug!("executing; cmd=cargo; args={:?}", os::args());
config.shell().set_verbose(flags.flag_verbose);
if flags.flag_list {
let (mut args, command) = match flags.arg_command.as_slice() {
"" | "help" if flags.arg_args.len() == 0 => {
config.shell().set_verbose(true);
- let args = &[os::args()[0].clone(), "-h".to_string()];
+ let args = &["foo".to_string(), "-h".to_string()];
let r = cargo::call_main_without_stdin(execute, config, USAGE, args,
false);
cargo::process_executed(r, &mut **config.shell());
s => (flags.arg_args.clone(), s),
};
args.insert(0, command.to_string());
- args.insert(0, os::args()[0].clone());
+ args.insert(0, "foo".to_string());
macro_rules! cmd{ ($name:ident) => (
if command.as_slice() == stringify!($name).replace("_", "-").as_slice() {
fn find_closest(cmd: &str) -> Option<String> {
match list_commands().iter()
- // doing it this way (instead of just .min_by(|c| c.lev_distance(cmd)))
- // allows us to only make suggestions that have an edit distance of
+ // doing it this way (instead of just .min_by(|c|
+ // c.lev_distance(cmd))) allows us to only make
+ // suggestions that have an edit distance of
// 3 or less
.map(|c| (lev_distance(c.as_slice(), cmd), c))
.filter(|&(d, _): &(usize, &String)| d < 4)
match status {
Ok(ExitStatus(0)) => (),
Ok(ExitStatus(i)) => {
- handle_error(CliError::new("", i as u32), shell)
+ handle_error(CliError::new("", i as i32), shell)
}
Ok(ExitSignal(i)) => {
let msg = format!("subcommand failed with signal: {}", i);
- handle_error(CliError::new(msg, i as u32), shell)
+ handle_error(CliError::new(msg, i as i32), shell)
}
Err(old_io::IoError{kind, ..}) if kind == old_io::FileNotFound =>
handle_error(CliError::new("No such subcommand", 127), shell),
_ => continue
};
if filename.starts_with(command_prefix) &&
- filename.ends_with(os::consts::EXE_SUFFIX) &&
+ filename.ends_with(env::consts::EXE_SUFFIX) &&
is_executable(entry) {
let command = &filename[
command_prefix.len()..
- filename.len() - os::consts::EXE_SUFFIX.len()];
+ filename.len() - env::consts::EXE_SUFFIX.len()];
commands.insert(String::from_str(command));
}
}
/// Get `Command` to run given command.
fn find_command(cmd: &str) -> Option<Path> {
- let command_exe = format!("cargo-{}{}", cmd, os::consts::EXE_SUFFIX);
+ let command_exe = format!("cargo-{}{}", cmd, env::consts::EXE_SUFFIX);
let dirs = list_command_directory();
let mut command_paths = dirs.iter().map(|dir| dir.join(command_exe.as_slice()));
command_paths.find(|path| path.exists())
/// List candidate locations where subcommands might be installed.
fn list_command_directory() -> Vec<Path> {
let mut dirs = vec![];
- match os::self_exe_path() {
- Some(path) => {
- dirs.push(path.join("../lib/cargo"));
- dirs.push(path);
- },
- None => {}
- };
- match std::os::getenv("PATH") {
- Some(val) => {
- for dir in os::split_paths(val).iter() {
- dirs.push(Path::new(dir))
- }
- },
- None => {}
- };
+ if let Ok(mut path) = env::current_exe() {
+ path.pop();
+ dirs.push(path.join("../lib/cargo"));
+ dirs.push(path);
+ }
+ if let Some(val) = env::var("PATH") {
+ dirs.extend(env::split_paths(&val));
+ }
dirs
}
None => Ok(None),
Some(err) => {
Err(match err.exit {
- Some(ExitStatus(i)) => CliError::from_boxed(box err, i as u32),
+ Some(ExitStatus(i)) => CliError::from_boxed(box err, i as i32),
_ => CliError::from_boxed(box err, 101),
})
}
None => Ok(None),
Some(err) => {
Err(match err.exit {
- Some(ExitStatus(i)) => CliError::new("", i as u32),
+ Some(ExitStatus(i)) => CliError::new("", i as i32),
_ => CliError::from_boxed(box Human(err), 101)
})
}
#![deny(unused)]
-#![feature(collections, core, hash, io, libc, os, path, std_misc, unicode)]
+#![feature(collections, hash, io, libc, os, path, std_misc, unicode, env, core)]
#![cfg_attr(test, deny(warnings))]
extern crate libc;
extern crate registry;
+use std::env;
use std::error::Error;
use std::old_io::stdio::{stdout_raw, stderr_raw};
use std::old_io::{self, stdout, stderr};
-use std::os;
use rustc_serialize::{Decodable, Encodable};
use rustc_serialize::json::{self, Json};
use docopt::Docopt;
use core::{Shell, MultiShell, ShellConfig};
use term::color::{BLACK, RED};
-pub use util::{CargoError, CliError, CliResult, human, Config};
+pub use util::{CargoError, CliError, CliResult, human, Config, ChainError};
pub mod core;
pub mod ops;
V: Encodable
{
let mut shell = shell(true);
- process_executed({
- match Config::new(&mut shell) {
- Ok(cfg) => callback(os::args().as_slice(), &cfg),
- Err(e) => Err(CliError::from_boxed(e, 101)),
- }
- }, &mut shell)
+ process_executed((|| {
+ let config = try!(Config::new(&mut shell));
+ let args: Vec<_> = try!(env::args().map(|s| {
+ s.into_string().map_err(|s| {
+ human(format!("invalid unicode in argument: {:?}", s))
+ })
+ }).collect());
+ callback(&args, &config)
+ })(), &mut shell)
}
pub fn process_executed<T>(result: CliResult<Option<T>>, shell: &mut MultiShell)
with --verbose.".to_string(), BLACK);
}
- std::os::set_exit_status(exit_code as isize);
+ std::env::set_exit_status(exit_code);
}
fn handle_cause(mut cargo_err: &CargoError, shell: &mut MultiShell) -> bool {
-use std::os;
-use std::old_io::{self, fs, File};
+use std::env;
use std::old_io::fs::PathExtensions;
+use std::old_io::{self, fs, File};
use rustc_serialize::{Decodable, Decoder};
let git_config = git_config.as_ref();
let name = git_config.and_then(|g| g.get_str("user.name").ok())
.map(|s| s.to_string())
- .or_else(|| os::getenv("USER")) // unix
- .or_else(|| os::getenv("USERNAME")); // windows
+ .or_else(|| env::var_string("USER").ok()) // unix
+ .or_else(|| env::var_string("USERNAME").ok()); // windows
let name = match name {
Some(name) => name,
None => {
use std::old_io::{fs, File, USER_DIR};
use std::old_io::fs::PathExtensions;
-use std::path;
+use std::old_path;
use tar::Archive;
use flate2::{GzBuilder, BestCompression};
shell.status("Archiving", relative.as_slice())
}));
let path = format!("{}-{}{}{}", pkg.get_name(),
- pkg.get_version(), path::SEP, relative);
+ pkg.get_version(), old_path::SEP, relative);
try!(ar.append(path.as_slice(), &mut file).chain_error(|| {
internal(format!("could not archive source file `{}`", relative))
}));
-use std::os;
use ops::{self, ExecEngine};
use util::{CargoResult, human, process, ProcessError, ChainError};
(None, true) => dst.join("examples").join(bin.get_name()),
(None, false) => dst.join(bin.get_name()),
};
- let exe = match exe.path_relative_from(&try!(os::getcwd())) {
+ let exe = match exe.path_relative_from(config.cwd()) {
Some(path) => path,
None => exe,
};
let process = try!(try!(compile.target_process(exe, &root))
.into_process_builder())
.args(args)
- .cwd(try!(os::getcwd()));
+ .cwd(config.cwd().clone());
try!(config.shell().status("Running", process.to_string()));
Ok(process.exec().err())
use std::collections::HashMap;
use std::dynamic_lib::DynamicLibrary;
use std::ffi::CString;
-use std::path::BytesContainer;
+use std::old_path::BytesContainer;
use semver::Version;
use core::{PackageId, Package};
use std::collections::HashMap;
+use std::env;
use std::ffi::CString;
use std::fmt::{self, Formatter};
use std::old_io::process::ProcessOutput;
-use std::os;
-use std::path::BytesContainer;
+use std::old_path::BytesContainer;
use util::{self, CargoResult, ProcessError, ProcessBuilder};
impl CommandPrototype {
pub fn new(ty: CommandType) -> CargoResult<CommandPrototype> {
- use std::os;
-
Ok(CommandPrototype {
ty: ty,
args: Vec::new(),
env: HashMap::new(),
- cwd: try!(os::getcwd()),
+ cwd: try!(env::current_dir()),
})
}
pub fn get_env(&self, var: &str) -> Option<CString> {
self.env.get(var).cloned().or_else(|| {
- Some(os::getenv(var).map(|s| CString::from_vec(s.into_bytes())))
+ Some(env::var_string(var).ok().map(|s| CString::from_vec(s.into_bytes())))
}).and_then(|val| val)
}
use std::ffi::CString;
use std::old_io::fs::{self, PathExtensions};
use std::os;
-use std::path;
+use std::old_path;
use std::sync::Arc;
use core::{SourceMap, Package, PackageId, PackageSet, Target, Resolve};
// For all plugin dependencies, add their -L paths (now calculated and
// present in `state`) to the dynamic library load path for the command to
// execute.
+#[allow(deprecated)] // need an OsStr based Command
fn add_plugin_deps(rustc: CommandPrototype,
build_state: &BuildMap,
plugin_deps: Vec<PackageId>)
v.push_all(target.get_name().as_bytes());
v.push(b'=');
v.push_all(layout.root().as_vec());
- v.push(path::SEP_BYTE);
+ v.push(old_path::SEP_BYTE);
v.push_all(filename.as_bytes());
cmd = cmd.arg("--extern").arg(v.as_slice());
}
-use std::os;
use core::Source;
use sources::PathSource;
target_name.map_or(true, |target_name| target_name == test_name.as_slice())
});
- let cwd = try!(os::getcwd());
+ let cwd = config.cwd();
for &(_, ref exe) in tests_to_run {
let to_display = match exe.path_relative_from(&cwd) {
Some(path) => path,
use std::collections::HashMap;
+use std::env;
+use std::iter::repeat;
use std::old_io::File;
use std::old_io::fs::PathExtensions;
-use std::iter::repeat;
-use std::os;
use curl::http;
use git2;
}
Err(..) => {}
}
- Ok(os::getenv("HTTP_PROXY"))
+ Ok(env::var_string("HTTP_PROXY").ok())
}
pub fn http_timeout(config: &Config) -> CargoResult<Option<i64>> {
Some((s, _)) => return Ok(Some(s)),
None => {}
}
- Ok(os::getenv("HTTP_TIMEOUT").and_then(|s| s.parse().ok()))
+ Ok(env::var_string("HTTP_TIMEOUT").ok().and_then(|s| s.parse().ok()))
}
pub fn registry_login(config: &Config, token: String) -> CargoResult<()> {
let RegistryConfig { index, token: _ } = try!(registry_configuration(config));
let mut map = HashMap::new();
- let p = try!(os::getcwd());
+ let p = config.cwd().clone();
match index {
Some(index) => {
map.insert("index".to_string(), ConfigValue::String(index, p.clone()));
-use std::{fmt, os, mem};
use std::cell::{RefCell, RefMut, Ref, Cell};
-use std::collections::hash_map::{HashMap};
use std::collections::hash_map::Entry::{Occupied, Vacant};
-use std::old_io;
+use std::collections::hash_map::{HashMap};
+use std::env;
+use std::fmt;
+use std::mem;
use std::old_io::fs::{self, PathExtensions, File};
+use std::old_io;
use rustc_serialize::{Encodable,Encoder};
use toml;
impl<'a> Config<'a> {
pub fn new(shell: &'a mut MultiShell) -> CargoResult<Config<'a>> {
- let cwd = try!(os::getcwd().chain_error(|| {
+ let cwd = try!(env::current_dir().chain_error(|| {
human("couldn't get the current directory of the process")
}));
let (rustc_version, rustc_host) = try!(ops::rustc_version());
}
fn homedir() -> Option<Path> {
- let cargo_home = os::getenv("CARGO_HOME").map(|p| Path::new(p));
- let user_home = os::homedir().map(|p| p.join(".cargo"));
+ let cargo_home = env::var_string("CARGO_HOME").map(|p| Path::new(p)).ok();
+ let user_home = env::home_dir().map(|p| p.join(".cargo"));
return cargo_home.or(user_home);
}
pub struct CliError {
pub error: Box<CargoError>,
pub unknown: bool,
- pub exit_code: u32
+ pub exit_code: i32
}
impl Error for CliError {
}
impl CliError {
- pub fn new<S: Str>(error: S, code: u32) -> CliError {
+ pub fn new<S: Str>(error: S, code: i32) -> CliError {
let error = human(error.as_slice().to_string());
CliError::from_boxed(error, code)
}
- pub fn from_error<E: CargoError + 'static>(error: E, code: u32) -> CliError {
+ pub fn from_error<E: CargoError + 'static>(error: E, code: i32) -> CliError {
let error = Box::new(error) as Box<CargoError>;
CliError::from_boxed(error, code)
}
- pub fn from_boxed(error: Box<CargoError>, code: u32) -> CliError {
+ pub fn from_boxed(error: Box<CargoError>, code: i32) -> CliError {
let human = error.is_human();
CliError { error: error, exit_code: code, unknown: !human }
}
}
+impl FromError<Box<CargoError>> for CliError {
+ fn from_error(err: Box<CargoError>) -> CliError {
+ CliError::from_boxed(err, 101)
+ }
+}
+
// =============================================================================
// various impls
-use std::os;
+use std::env;
use std::old_io::fs::PathExtensions;
-use util::{CargoResult, CliError, CliResult, human};
+use util::{CargoResult, human, ChainError};
/// Iteratively search for `file` in `pwd` and its parents, returning
/// the path of the directory.
pub fn find_project(pwd: &Path, file: &str) -> CargoResult<Path> {
- find_project_manifest(pwd, file)
- .map(|mut p| {
- // remove the file, leaving just the directory
- p.pop();
- p
- })
+ find_project_manifest(pwd, file).map(|mut p| {
+ // remove the file, leaving just the directory
+ p.pop();
+ p
+ })
}
/// Iteratively search for `file` in `pwd` and its parents, returning
}
/// Find the root Cargo.toml
-pub fn find_root_manifest_for_cwd(manifest_path: Option<String>) -> CliResult<Path> {
- manifest_path.map(|path| Ok(Path::new(path))).unwrap_or_else(|| os::getcwd()
- .map_err(|_| CliError::new("Couldn't determine the current working directory", 103))
- .and_then(|cwd| find_project_manifest(&cwd, "Cargo.toml")
- .map_err(|_| CliError::new("Could not find Cargo.toml in this \
- directory or any parent directory", 102))
- )
- )
- .and_then(|path| os::make_absolute(&path).map_err(|_|
- CliError::new("Could not determine the absolute path of the manifest", 104)))
+pub fn find_root_manifest_for_cwd(manifest_path: Option<String>)
+ -> CargoResult<Path> {
+ let cwd = try!(env::current_dir().chain_error(|| {
+ human("Couldn't determine the current working directory")
+ }));
+ match manifest_path {
+ Some(path) => Ok(cwd.join(path)),
+ None => find_project_manifest(&cwd, "Cargo.toml"),
+ }
}
/// Return the path to the `file` in `pwd`, if it exists.
-use std::{old_io,os};
+use std::env;
use std::old_io::fs;
-use std::path::BytesContainer;
+use std::old_io;
+use std::old_path::BytesContainer;
+use std::os;
use util::{human, CargoResult};
pub fn realpath(original: &Path) -> old_io::IoResult<Path> {
const MAX_LINKS_FOLLOWED: usize = 256;
- let original = try!(os::make_absolute(original));
+ let cwd = try!(env::current_dir());
+ let original = cwd.join(original);
// Right now lstat on windows doesn't work quite well
if cfg!(windows) {
return Ok(result);
}
+#[allow(deprecated)] // need an OsStr-based Command first
pub fn join_paths<T: BytesContainer>(paths: &[T], env: &str)
-> CargoResult<Vec<u8>> {
os::join_paths(paths).map_err(|e| {
use std::collections::HashMap;
+use std::env;
use std::ffi::CString;
use std::fmt::{self, Formatter};
use std::old_io::process::{Command, ProcessOutput, InheritFd};
-use std::os;
-use std::path::BytesContainer;
+use std::old_path::BytesContainer;
use util::{CargoResult, ProcessError, process_error};
Ok(ProcessBuilder {
program: CString::from_slice(cmd.container_as_bytes()),
args: Vec::new(),
- cwd: try!(os::getcwd()),
+ cwd: try!(env::current_dir()),
env: HashMap::new(),
})
}
-use std::os;
-use std::mem;
+use std::env;
use std::fmt;
+use std::mem;
use time;
use std::iter::repeat;
use std::cell::RefCell;
desc: String,
}
-fn enabled() -> bool { os::getenv("CARGO_PROFILE").is_some() }
+fn enabled() -> bool { env::var("CARGO_PROFILE").is_some() }
pub fn start<T: fmt::Display>(desc: T) -> Profiler {
if !enabled() { return Profiler { desc: String::new() } }
use std::fmt;
use std::old_io::fs::{self, PathExtensions};
-use std::os;
use std::slice;
use std::str;
use std::default::Default;
config: &Config)
-> CargoResult<(Manifest, Vec<Path>)> {
let manifest = layout.root.join("Cargo.toml");
- let manifest = match manifest.path_relative_from(&try!(os::getcwd())) {
+ let manifest = match manifest.path_relative_from(config.cwd()) {
Some(path) => path,
None => manifest,
};
use std::error::Error;
+use std::env;
use std::fmt;
use std::old_io::fs::{self, PathExtensions};
use std::old_io::process::{ProcessOutput};
use std::old_io;
-use std::os;
-use std::path::{Path, BytesContainer};
+use std::old_path::{Path, BytesContainer};
use std::str::{self, Str};
use url::Url;
pub fn url(&self) -> Url { path2url(self.root()) }
pub fn bin(&self, b: &str) -> Path {
- self.build_dir().join(format!("{}{}", b, os::consts::EXE_SUFFIX))
+ self.build_dir().join(format!("{}{}", b, env::consts::EXE_SUFFIX))
}
pub fn release_bin(&self, b: &str) -> Path {
- self.build_dir().join("release").join(format!("{}{}", b, os::consts::EXE_SUFFIX))
+ self.build_dir().join("release").join(format!("{}{}", b,
+ env::consts::EXE_SUFFIX))
}
pub fn target_bin(&self, target: &str, b: &str) -> Path {
self.build_dir().join(target).join(format!("{}{}", b,
- os::consts::EXE_SUFFIX))
+ env::consts::EXE_SUFFIX))
}
pub fn build_dir(&self) -> Path {
// Path to cargo executables
pub fn cargo_dir() -> Path {
- os::getenv("CARGO_BIN_PATH").map(Path::new)
- .or_else(|| os::self_exe_path())
+ env::var_string("CARGO_BIN_PATH").map(Path::new).ok()
+ .or_else(|| env::current_exe().ok().map(|s| s.dir_path()))
.unwrap_or_else(|| {
panic!("CARGO_BIN_PATH wasn't set. Cannot continue running test")
})
use std::old_io::IoResult;
+use std::env;
use std::old_io::fs::{self, PathExtensions};
use std::sync::atomic::{AtomicUsize, ATOMIC_USIZE_INIT, Ordering};
-use std::{old_io, os};
+use std::old_io;
use cargo::util::realpath;
thread_local!(static TASK_ID: usize = NEXT_ID.fetch_add(1, Ordering::SeqCst));
pub fn root() -> Path {
- let path = os::self_exe_path().unwrap()
+ let path = env::current_exe().unwrap()
+ .dir_path()
.join(CARGO_INTEGRATION_TEST_DIR)
.join(TASK_ID.with(|my_id| format!("test-{}", my_id)));
realpath(&path).unwrap()
+use std::env;
+use std::ffi::OsString;
use std::old_io::fs;
-use std::old_io;
use std::old_io::{USER_RWX, File};
-use std::os;
+use std::old_io;
use std::str;
use cargo::util::process;
/// Add an empty file with executable flags (and platform-dependent suffix).
/// TODO: move this to `ProjectBuilder` if other cases using this emerge.
fn fake_executable(proj: ProjectBuilder, dir: &Path, name: &str) -> ProjectBuilder {
- let path = proj.root().join(dir).join(format!("{}{}", name, os::consts::EXE_SUFFIX));
+ let path = proj.root().join(dir).join(format!("{}{}", name, env::consts::EXE_SUFFIX));
mkdir_recursive(&Path::new(path.dirname())).unwrap();
fs::File::create(&path).unwrap();
let old_io::FileStat{perm, ..} = fs::stat(&path).unwrap();
}
fn path() -> Vec<Path> {
- let path = os::getenv_as_bytes("PATH").unwrap_or(Vec::new());
- os::split_paths(path)
+ env::split_paths(&env::var("PATH").unwrap_or(OsString::new())).collect()
}
+
test!(list_commands_looks_at_path {
let proj = project("list-non-overlapping");
let proj = fake_executable(proj, &Path::new("path-test"), "cargo-1");
let mut path = path();
path.push(proj.root().join("path-test"));
- let path = os::join_paths(path.as_slice()).unwrap();
- let output = pr.arg("-v").arg("--list").env("PATH", Some(path.as_slice()));
+ let path = env::join_paths(path.iter()).unwrap();
+ let output = pr.arg("-v").arg("--list")
+ .env("PATH", Some(path.to_str().unwrap()));
let output = output.exec_with_output().unwrap();
let output = str::from_utf8(output.output.as_slice()).unwrap();
assert!(output.contains("\n 1\n"), "missing 1: {}", output);
-use std::path;
+use std::old_path;
use std::str;
use support::{project, execs, basic_bin_manifest, basic_lib_manifest};
`(left == right) && (right == left)` (left: \
`\"hello\"`, right: `\"nope\"`)', src{sep}foo.rs:14
-", sep = path::SEP))
+", sep = old_path::SEP))
.with_status(101));
});
running = RUNNING,
dir = p.root().display(),
url = p.url(),
- sep = path::SEP).as_slice()));
+ sep = old_path::SEP).as_slice()));
});
-use std::path;
+use std::old_path;
use support::{basic_bin_manifest, execs, project, ProjectBuilder};
use support::{COMPILING, RUNNING};
use hamcrest::{assert_that};
-L dependency={dir}{sep}target \
-L dependency={dir}{sep}target{sep}deps`
",
- running = RUNNING, compiling = COMPILING, sep = path::SEP,
+ running = RUNNING, compiling = COMPILING, sep = old_path::SEP,
dir = p.root().display(), url = p.url(),
name = "foo", version = "0.0.1")
}
use std::old_io::{self, fs, TempDir, File};
-use std::os;
-use std::path;
+use std::env;
+use std::old_path;
use support::{project, execs, main_file, basic_bin_manifest};
use support::{COMPILING, RUNNING, cargo_dir, ProjectBuilder};
let p = ProjectBuilder::new("foo", tmpdir.path().clone());
assert_that(p.cargo_process("build"),
- execs()
- .with_status(102)
- .with_stderr("Could not find Cargo.toml in this directory or any \
- parent directory\n"));
+ execs().with_status(101)
+ .with_stderr("\
+Could not find `Cargo.toml` in `[..]` or any parent directory
+"));
});
test!(cargo_compile_with_invalid_code {
Could not compile `foo`.
To learn more, run the command again with --verbose.\n",
- filename = format!("src{}foo.rs", path::SEP)).as_slice()));
+ filename = format!("src{}foo.rs", old_path::SEP)).as_slice()));
assert_that(&p.root().join("Cargo.lock"), existing_file());
});
on by default
{filename}:1 fn main() {{}} fn dead() {{}}
^~~~~~~~~~~~
-", filename = format!("src{}foo.rs", path::SEP).as_slice())));
+", filename = format!("src{}foo.rs", old_path::SEP).as_slice())));
});
test!(cargo_compile_with_warnings_in_a_dep_package {
let file1 = files[1].as_slice();
println!("{} {}", file0, file1);
assert!(file0.ends_with(".rlib") || file1.ends_with(".rlib"));
- assert!(file0.ends_with(os::consts::DLL_SUFFIX) ||
- file1.ends_with(os::consts::DLL_SUFFIX));
+ assert!(file0.ends_with(env::consts::DLL_SUFFIX) ||
+ file1.ends_with(env::consts::DLL_SUFFIX));
});
test!(many_crate_types_correct {
let file1 = files[1].as_slice();
println!("{} {}", file0, file1);
assert!(file0.ends_with(".rlib") || file1.ends_with(".rlib"));
- assert!(file0.ends_with(os::consts::DLL_SUFFIX) ||
- file1.ends_with(os::consts::DLL_SUFFIX));
+ assert!(file0.ends_with(env::consts::DLL_SUFFIX) ||
+ file1.ends_with(env::consts::DLL_SUFFIX));
});
test!(unused_keys {
-L dependency={dir}{sep}target{sep}release \
-L dependency={dir}{sep}target{sep}release{sep}deps`
",
-running = RUNNING, compiling = COMPILING, sep = path::SEP,
+running = RUNNING, compiling = COMPILING, sep = old_path::SEP,
dir = p.root().display(),
url = p.url(),
)));
-L dependency={dir}{sep}target \
-L dependency={dir}{sep}target{sep}deps`
",
-running = RUNNING, compiling = COMPILING, sep = path::SEP,
+running = RUNNING, compiling = COMPILING, sep = old_path::SEP,
dir = p.root().display(),
url = p.url(),
)));
-L dependency={dir}{sep}target{sep}release \
-L dependency={dir}{sep}target{sep}release{sep}deps`
",
-running = RUNNING, compiling = COMPILING, sep = path::SEP,
+running = RUNNING, compiling = COMPILING, sep = old_path::SEP,
dir = p.root().display(),
url = p.url(),
)));
compiling = COMPILING,
dir = p.root().display(),
url = p.url(),
- sep = path::SEP,
- prefix = os::consts::DLL_PREFIX,
- suffix = os::consts::DLL_SUFFIX).as_slice()));
+ sep = old_path::SEP,
+ prefix = env::consts::DLL_PREFIX,
+ suffix = env::consts::DLL_SUFFIX).as_slice()));
});
test!(explicit_examples {
build = 'build.rs'
"#)
.file("build.rs", r#"
- use std::os;
+ use std::env;
use std::old_io::File;
fn main() {
- let path = Path::new(os::getenv("OUT_DIR").unwrap()).join("foo");
- if os::getenv("FIRST").is_some() {
+ let path = Path::new(env::var_string("OUT_DIR").unwrap()).join("foo");
+ if env::var("FIRST").is_some() {
File::create(&path).unwrap();
} else {
File::create(&path).unwrap();
+use std::env;
use std::old_io::{File, fs};
-use std::os;
use support::{project, execs, cargo_dir};
use support::{COMPILING, RUNNING, DOCTEST};
fn main() {}
"#)
.file("build.rs", r#"
- #![feature(os)]
+ #![feature(env)]
fn main() {
- std::os::set_exit_status(101);
+ std::env::set_exit_status(101);
}
"#);
assert_that(p.cargo_process("build").arg("-v"),
"#);
let file_content = format!(r#"
- use std::os;
+ use std::env;
use std::old_io::fs::PathExtensions;
fn main() {{
- let _target = os::getenv("TARGET").unwrap();
+ let _target = env::var_string("TARGET").unwrap();
- let _ncpus = os::getenv("NUM_JOBS").unwrap();
+ let _ncpus = env::var_string("NUM_JOBS").unwrap();
- let out = os::getenv("CARGO_MANIFEST_DIR").unwrap();
+ let out = env::var_string("CARGO_MANIFEST_DIR").unwrap();
let p1 = Path::new(out);
- let p2 = os::make_absolute(&Path::new(file!()).dir_path().dir_path()).unwrap();
+ let cwd = env::current_dir().unwrap();
+ let p2 = cwd.join(Path::new(file!()).dir_path().dir_path());
assert!(p1 == p2, "{{}} != {{}}", p1.display(), p2.display());
- let opt = os::getenv("OPT_LEVEL").unwrap();
+ let opt = env::var_string("OPT_LEVEL").unwrap();
assert_eq!(opt.as_slice(), "0");
- let opt = os::getenv("PROFILE").unwrap();
+ let opt = env::var_string("PROFILE").unwrap();
assert_eq!(opt.as_slice(), "compile");
- let debug = os::getenv("DEBUG").unwrap();
+ let debug = env::var_string("DEBUG").unwrap();
assert_eq!(debug.as_slice(), "true");
- let out = os::getenv("OUT_DIR").unwrap();
+ let out = env::var_string("OUT_DIR").unwrap();
assert!(out.as_slice().starts_with(r"{0}"));
assert!(Path::new(out).is_dir());
- let _host = os::getenv("HOST").unwrap();
+ let _host = env::var_string("HOST").unwrap();
- let _feat = os::getenv("CARGO_FEATURE_FOO").unwrap();
+ let _feat = env::var_string("CARGO_FEATURE_FOO").unwrap();
}}
"#,
p.root().join("target").join("build").display());
"#)
.file("src/lib.rs", "")
.file("build.rs", r#"
- use std::os;
+ use std::env;
fn main() {
- assert_eq!(os::getenv("DEP_FOO_FOO").unwrap().as_slice(), "bar");
- assert_eq!(os::getenv("DEP_FOO_BAR").unwrap().as_slice(), "baz");
+ assert_eq!(env::var_string("DEP_FOO_FOO").unwrap().as_slice(), "bar");
+ assert_eq!(env::var_string("DEP_FOO_BAR").unwrap().as_slice(), "baz");
}
"#)
.file(".cargo/config", format!(r#"
"#)
.file("src/lib.rs", "")
.file("build.rs", r#"
- use std::os;
+ use std::env;
fn main() {
- assert_eq!(os::getenv("DEP_FOO_FOO").unwrap().as_slice(), "bar");
- assert_eq!(os::getenv("DEP_FOO_BAR").unwrap().as_slice(), "baz");
+ assert_eq!(env::var_string("DEP_FOO_FOO").unwrap().as_slice(), "bar");
+ assert_eq!(env::var_string("DEP_FOO_BAR").unwrap().as_slice(), "baz");
}
"#)
.file("a/Cargo.toml", r#"
"#, a.root().display()))
.file("src/lib.rs", "")
.file("build.rs", r#"
- use std::os;
+ use std::env;
fn main() {
- assert_eq!(os::getenv("DEP_FOO_FOO").unwrap().as_slice(), "bar");
- assert_eq!(os::getenv("DEP_FOO_BAR").unwrap().as_slice(), "baz");
+ assert_eq!(env::var_string("DEP_FOO_FOO").unwrap().as_slice(), "bar");
+ assert_eq!(env::var_string("DEP_FOO_BAR").unwrap().as_slice(), "baz");
}
"#);
"#)
.file("src/lib.rs", "")
.file("build.rs", r#"
- use std::os;
+ use std::env;
use std::old_io::File;
fn main() {
- let out = os::getenv("OUT_DIR").unwrap();
+ let out = env::var_string("OUT_DIR").unwrap();
File::create(&Path::new(out).join("foo")).unwrap();
}
"#);
// Change to asserting that it's there
File::create(&p.root().join("build.rs")).write_str(r#"
- use std::os;
+ use std::env;
use std::old_io::File;
fn main() {
- let out = os::getenv("OUT_DIR").unwrap();
+ let out = env::var_string("OUT_DIR").unwrap();
File::open(&Path::new(out).join("foo")).unwrap();
}
"#).unwrap();
}
"#)
.file("build.rs", r#"
- use std::os;
+ use std::env;
use std::old_io::File;
fn main() {
- let dst = Path::new(os::getenv("OUT_DIR").unwrap());
+ let dst = Path::new(env::var_string("OUT_DIR").unwrap());
let mut f = File::create(&dst.join("hello.rs")).unwrap();
f.write_str("
pub fn message() -> &'static str {
}
"#)
.file("build.rs", r#"
- use std::os;
+ use std::env;
use std::old_io::File;
fn main() {
- let out = Path::new(os::getenv("OUT_DIR").unwrap());
+ let out = Path::new(env::var_string("OUT_DIR").unwrap());
File::create(&out.join("foo.rs")).write_str("
fn foo() -> int { 1 }
").unwrap();
let src = build.root().join("target");
let lib = fs::readdir(&src).unwrap().into_iter().find(|lib| {
let lib = lib.filename_str().unwrap();
- lib.starts_with(os::consts::DLL_PREFIX) &&
- lib.ends_with(os::consts::DLL_SUFFIX)
+ lib.starts_with(env::consts::DLL_PREFIX) &&
+ lib.ends_with(env::consts::DLL_SUFFIX)
}).unwrap();
let libname = lib.filename_str().unwrap();
- let libname = &libname[os::consts::DLL_PREFIX.len()..
- libname.len() - os::consts::DLL_SUFFIX.len()];
+ let libname = &libname[env::consts::DLL_PREFIX.len()..
+ libname.len() - env::consts::DLL_SUFFIX.len()];
let foo = project("foo")
.file("Cargo.toml", r#"
build = "build.rs"
"#)
.file("bar/build.rs", r#"
- use std::os;
+ use std::env;
fn main() {
- let src = Path::new(os::getenv("SRC").unwrap());
+ let src = Path::new(env::var_string("SRC").unwrap());
println!("cargo:rustc-flags=-L {}", src.dir_path().display());
}
"#)
use std::old_io::fs;
-use std::os;
+use std::env;
use support::{project, execs, cargo_dir};
use hamcrest::assert_that;
let src = build.root().join("target");
let lib = fs::readdir(&src).unwrap().into_iter().find(|lib| {
let lib = lib.filename_str().unwrap();
- lib.starts_with(os::consts::DLL_PREFIX) &&
- lib.ends_with(os::consts::DLL_SUFFIX)
+ lib.starts_with(env::consts::DLL_PREFIX) &&
+ lib.ends_with(env::consts::DLL_SUFFIX)
}).unwrap();
let libname = lib.filename_str().unwrap();
- let libname = &libname[os::consts::DLL_PREFIX.len()..
- libname.len() - os::consts::DLL_SUFFIX.len()];
+ let libname = &libname[env::consts::DLL_PREFIX.len()..
+ libname.len() - env::consts::DLL_SUFFIX.len()];
let foo = project("foo")
.file("Cargo.toml", r#"
-use std::os;
-use std::path;
+use std::env;
+use std::old_path;
use support::{project, execs, basic_bin_manifest};
use support::{RUNNING, COMPILING, DOCTEST, cargo_dir};
fn disabled() -> bool {
// First, disable if ./configure requested so
- match os::getenv("CFG_DISABLE_CROSS_TESTS") {
- Some(ref s) if s.as_slice() == "1" => return true,
+ match env::var_string("CFG_DISABLE_CROSS_TESTS") {
+ Ok(ref s) if s.as_slice() == "1" => return true,
_ => {}
}
}
fn alternate() -> &'static str {
- match os::consts::SYSNAME {
+ match env::consts::OS {
"linux" => "i686-unknown-linux-gnu",
"macos" => "i686-apple-darwin",
_ => unreachable!(),
"#)
.file("build.rs", format!(r#"
fn main() {{
- assert_eq!(std::os::getenv("TARGET").unwrap().as_slice(), "{}");
+ assert_eq!(std::env::var_string("TARGET").unwrap().as_slice(), "{}");
}}
"#, alternate()).as_slice())
.file("src/main.rs", r#"
- use std::os;
+ use std::env;
fn main() {
- assert_eq!(os::consts::ARCH, "x86");
+ assert_eq!(env::consts::ARCH, "x86");
}
"#);
"#, target).as_slice())
.file("Cargo.toml", basic_bin_manifest("foo").as_slice())
.file("src/foo.rs", r#"
- use std::os;
+ use std::env;
fn main() {
- assert_eq!(os::consts::ARCH, "x86");
+ assert_eq!(env::consts::ARCH, "x86");
}
"#);
dir = p.root().display(),
url = p.url(),
target = target,
- sep = path::SEP,
+ sep = old_path::SEP,
).as_slice()));
});
"#)
.file("src/main.rs", r#"
extern crate foo;
- use std::os;
+ use std::env;
fn main() {
- assert_eq!(os::consts::ARCH, "x86");
+ assert_eq!(env::consts::ARCH, "x86");
}
#[test] fn test() { main() }
"#)
.file("src/lib.rs", r#"
- use std::os;
- pub fn foo() { assert_eq!(os::consts::ARCH, "x86"); }
+ use std::env;
+ pub fn foo() { assert_eq!(env::consts::ARCH, "x86"); }
#[test] fn test_foo() { foo() }
"#);
authors = []
"#)
.file("src/main.rs", r#"
- use std::os;
+ use std::env;
fn main() {
- assert_eq!(os::consts::ARCH, "x86");
+ assert_eq!(env::consts::ARCH, "x86");
}
"#);
build = 'build.rs'
"#)
.file("build.rs", format!(r#"
- use std::os;
+ use std::env;
fn main() {{
- assert_eq!(os::getenv("TARGET").unwrap().as_slice(), "{0}");
- let mut path = Path::new(os::getenv("OUT_DIR").unwrap());
+ assert_eq!(env::var_string("TARGET").unwrap().as_slice(), "{0}");
+ let mut path = Path::new(env::var_string("OUT_DIR").unwrap());
assert_eq!(path.filename().unwrap(), b"out");
path.pop();
assert!(path.filename().unwrap().starts_with(b"foo-"));
{running} `{dir}{sep}target{sep}build{sep}foo-[..]build-script-build`
{running} `rustc src{sep}main.rs [..] --target {target} [..]`
", compiling = COMPILING, running = RUNNING, target = target,
- dir = p.root().display(), sep = path::SEP).as_slice()));
+ dir = p.root().display(), sep = old_path::SEP).as_slice()));
});
test!(build_script_needed_for_host_and_target {
pub fn d1() {}
")
.file("d1/build.rs", r#"
- use std::os;
+ use std::env;
fn main() {
- let target = os::getenv("TARGET").unwrap();
+ let target = env::var_string("TARGET").unwrap();
println!("cargo:rustc-flags=-L /path/to/{}", target);
}
"#)
{running} `rustc src{sep}main.rs [..] --target {target} [..] \
-L /path/to/{target}`
", compiling = COMPILING, running = RUNNING, target = target, host = host,
- dir = p.root().display(), sep = path::SEP).as_slice()));
+ dir = p.root().display(), sep = old_path::SEP).as_slice()));
});
test!(build_deps_for_the_right_arch {
pub fn d1() {}
")
.file("d1/build.rs", r#"
- use std::os;
+ use std::env;
fn main() {
- assert!(os::getenv("OUT_DIR").unwrap()
+ assert!(env::var_string("OUT_DIR").unwrap()
.contains("target/build/d1-"),
- "bad: {:?}", os::getenv("OUT_DIR"));
+ "bad: {:?}", env::var_string("OUT_DIR"));
}
"#);
use std::old_io::{fs, USER_RWX, File, TempDir};
use std::old_io::fs::PathExtensions;
-use std::os;
+use std::env;
use support::{execs, paths, cargo_dir};
use hamcrest::{assert_that, existing_file, existing_dir, is_not};
}
test!(simple_lib {
- os::setenv("USER", "foo");
- assert_that(cargo_process("new").arg("foo").arg("--vcs").arg("none"),
+ assert_that(cargo_process("new").arg("foo").arg("--vcs").arg("none")
+ .env("USER", Some("foo")),
execs().with_status(0));
assert_that(&paths::root().join("foo"), existing_dir());
});
test!(simple_bin {
- os::setenv("USER", "foo");
- assert_that(cargo_process("new").arg("foo").arg("--bin"),
+ assert_that(cargo_process("new").arg("foo").arg("--bin")
+ .env("USER", Some("foo")),
execs().with_status(0));
assert_that(&paths::root().join("foo"), existing_dir());
assert_that(cargo_process("build").cwd(paths::root().join("foo")),
execs().with_status(0));
assert_that(&paths::root().join(format!("foo/target/foo{}",
- os::consts::EXE_SUFFIX)),
+ env::consts::EXE_SUFFIX)),
existing_file());
});
test!(simple_git {
let td = TempDir::new("cargo").unwrap();
- os::setenv("USER", "foo");
- assert_that(cargo_process("new").arg("foo").cwd(td.path().clone()),
+ assert_that(cargo_process("new").arg("foo").cwd(td.path().clone())
+ .env("USER", Some("foo")),
execs().with_status(0));
assert_that(td.path(), existing_dir());
});
test!(subpackage_no_git {
- os::setenv("USER", "foo");
- assert_that(cargo_process("new").arg("foo"), execs().with_status(0));
+ assert_that(cargo_process("new").arg("foo").env("USER", Some("foo")),
+ execs().with_status(0));
let subpackage = paths::root().join("foo").join("components");
fs::mkdir(&subpackage, USER_RWX).unwrap();
use std::os;
-use std::path;
+use std::old_path;
use support::{project, execs};
use support::{COMPILING, RUNNING};
-L dependency={dir}{sep}target \
-L dependency={dir}{sep}target{sep}deps`
",
-running = RUNNING, compiling = COMPILING, sep = path::SEP,
+running = RUNNING, compiling = COMPILING, sep = old_path::SEP,
dir = p.root().display(),
url = p.url(),
)));
compiling = COMPILING,
dir = p.root().display(),
url = p.url(),
- sep = path::SEP,
+ sep = old_path::SEP,
prefix = os::consts::DLL_PREFIX,
suffix = os::consts::DLL_SUFFIX).as_slice()));
});
-use std::path;
+use std::old_path;
use support::{project, cargo_dir, execs, path2url};
use support::{COMPILING, RUNNING};
compiling = COMPILING,
running = RUNNING,
dir = path2url(p.root()),
- sep = path::SEP).as_slice()));
+ sep = old_path::SEP).as_slice()));
assert_that(&p.bin("foo"), existing_file());
});
compiling = COMPILING,
running = RUNNING,
dir = path2url(p.root()),
- sep = path::SEP).as_slice()));
+ sep = old_path::SEP).as_slice()));
assert_that(p.process(cargo_dir().join("cargo")).arg("run").arg("--bin").arg("b"),
execs().with_status(0).with_stdout(format!("\
hello b.rs
",
running = RUNNING,
- sep = path::SEP).as_slice()));
+ sep = old_path::SEP).as_slice()));
});
test!(run_example {
compiling = COMPILING,
running = RUNNING,
dir = path2url(p.root()),
- sep = path::SEP).as_slice()));
+ sep = old_path::SEP).as_slice()));
});
test!(either_name_or_example {
compiling = COMPILING,
running = RUNNING,
dir = path2url(p.root()),
- sep = path::SEP).as_slice()));
+ sep = old_path::SEP).as_slice()));
});
test!(example_with_release_flag {
running = RUNNING,
dir = p.root().display(),
url = path2url(p.root()),
- sep = path::SEP).as_slice()));
+ sep = old_path::SEP).as_slice()));
assert_that(p.process(cargo_dir().join("cargo")).arg("run").arg("-v").arg("--example").arg("a"),
execs().with_status(0).with_stdout(format!("\
running = RUNNING,
dir = p.root().display(),
url = path2url(p.root()),
- sep = path::SEP).as_slice()));
+ sep = old_path::SEP).as_slice()));
});
test!(run_dylib_dep {
compiling = COMPILING,
running = RUNNING,
dir = path2url(p.root()),
- sep = path::SEP).as_slice()));
+ sep = old_path::SEP).as_slice()));
assert_that(&p.release_bin("foo"), existing_file());
});
-use std::path;
+use std::old_path;
use std::str;
use support::{project, execs, basic_bin_manifest, basic_lib_manifest};
",
COMPILING, p.url(), RUNNING,
- sep = path::SEP))
+ sep = old_path::SEP))
.with_stderr(format!("\
thread '<main>' panicked at 'Some tests failed', [..]
#![deny(warnings)]
-#![feature(collections, core, io, os, path, rustc_private, std_misc)]
+#![feature(collections, core, io, os, path, rustc_private, std_misc, env)]
extern crate cargo;
extern crate flate2;